package frontend.parser.node.decl;

import frontend.lexer.token.Token;
import frontend.parser.node.Node;
import frontend.parser.node.TokenNode;
import frontend.parser.node.expnode.ConstExp;

public class FuncFParam extends Node {
    // 函数形参    FuncFParam → BType Ident ['[' ']' { '[' ConstExp ']' }]  //   b k
    private TokenNode identTokenNode;
    private int dimension = 0;
    private ConstExp[] dimLenConstExp = new ConstExp[2];
    public void addIdentTokenNode(TokenNode identTokenNode) {
        super.add(identTokenNode);
        this.identTokenNode = identTokenNode;
    }
    public void addRbrackTokenNode(TokenNode rbrackTokenNode) {
        super.add(identTokenNode);
        dimension++;
    }
    public void addDimLenConstExp(ConstExp lenConstExp) {
        super.add(lenConstExp);
        if (dimension < 2) {
            dimLenConstExp[dimension] = lenConstExp;
        }
    }

    public int getDimension() {
        return dimension;
    }

    public ConstExp[] getDimLenConstExp() {
        return dimLenConstExp;
    }

    public String getIdentName() {
        return identTokenNode.getContent();
    }

    public Token getIdentToken() {
        return identTokenNode.getToken();
    }

    // symbol manager
//    private ParaSymbol paraSymbol;
//    public ParaSymbol toParaSymbol() {
//        return (this.paraSymbol =
//                new ParaSymbol(identTokenNode, dimension, dimLenConstExp));
//    }
//
//    public ParaSymbol getParaSymbol() {
//        return paraSymbol;
//    }
}
